<?php  
/**
 * class BaseEntity
 *
 * @package com.yamvc.orm.entity
 * @author miho
 */ 
class BaseEntity{
    protected $_rows;
    protected $_map;
    
    public function __construct(){
        $this->_rows = array();
    }
    
    
    protected function _initialize(){
        $this->_map = EntityMaper::getInstance()->map($this)
             ->addField('id','post','id')
             ->addField('title','post','title')
             ->addField('body','post','body')
             ->addField('author','post','author_id','com.miho.blog.model.entity.UserEntity');
    }
    
    public function __get($name){
        if(!isset($this->_rows[$name])){
            throw new Error('Field "'.$name.'" does not exist.');
        }
        return $this->_rows[$name];
    }
    
    public function __set($name,$value){
        if(!isset($this->_rows[$name])){
            throw new Error('Field "'.$name.'" does not exist.');
        }
        $this->_rows[$name] = $value;
    }
    
    /**
     * Create and update entity
     *
     * @return void
     * @author miho
     */
    public function save(){
        
    }
    
    /**
     * Delete entity
     *
     * @return void
     * @author miho
     */
    public function delete(){
        
    }
}

?>